/* c2.c
 *	Simple program to help perform multi-client test using networking to implement lock/cv/mv-related syscalls
 *	
 *	Does syscalls that create, acquire, release, and destroy locks and create, wait, signal, broadcast, and destory CVs, create, set, get, destory MVs
 *  through connection to a server. Will be used with one single-threaded server process and up to 5 single-threaded client processes.
 */
#include "syscall.h"

void foo(void);
void Dummy(void);

int main(int argc, char **argv)
{   
	void (*myFoo)(void);
	void (*myDummy)(void); /*For some reason if you fork just once, nothing works*/
	myFoo = &foo;
	myDummy = &Dummy;
	Fork(myFoo);
	Fork(myDummy);
	
    Exit(0);
}

void Dummy()
{
	PrintOut("Dummy Thread\n", 13);
    Exit(0);		
}

void foo()
{
	int lockIndex, cvIndex, mvIndex;
    lockIndex = CreateLock("KenLock", 7, 1);
	Acquire(lockIndex);
	cvIndex = CreateCV("KenCV", 5, 1);
	mvIndex = CreateMV("KenMV", 5, 1);
	SetMV(mvIndex, 1); /*first int is index of MV, and second int is value to set it to*/
	/*Wait(cvIndex, lockIndex);*/
	Release(lockIndex);
}
